****# Freezer Backend API Documentation
The Freezer Backend API provides endpoints for managing users, food nutrients, images, body data, blog content, scan documents, and database dashboard functionality.
Base URL: https://api.ashesborn.cloud (or your deployed URL)
Most endpoints require authentication using JWT tokens. Include the token in the request headers:
textAuthorization: Bearer <your-jwt-token>
Or as a cookie (for web applications):
textCookie: token=<your-jwt-token>
/Returns the API status.
Response:
json{ "message": "Freezer Backend API is running!" }
/healthReturns detailed health information.
Response:
json{ "status": "OK", "timestamp": "2025-07-30T12:00:00.000Z" }
Base URL: /api/users
/api/users/registerRegister a new user account.
Request Body:
json{ "email": "user@example.com", "name": "John Doe", "password": "password123", "role": "USER" // Optional, defaults to USER }
Response:
json{ "message": "User registered successfully", "user": { "id": 1, "email": "user@example.com", "name": "John Doe", "role": "USER" } }
/api/users/loginAuthenticate a user and receive a JWT token.
Request Body:
json{ "email": "user@example.com", "password": "password123" }
Response:
json{ "message": "Login successful", "user": { "id": 1, "email": "user@example.com", "name": "John Doe", "role": "USER" } }
Note: JWT token is set as an httpOnly cookie
/api/users/meGet the current authenticated user's information.
Headers: Authorization: Bearer <token>
Response:
json{ "id": 1, "email": "user@example.com", "name": "John Doe", "role": "USER" }
/api/usersGet all users in the system.
Headers: Authorization: Bearer <admin-token>
Response:
json[ { "id": 1, "email": "user@example.com", "name": "John Doe", "role": "USER" } ]
/api/users/:idGet a specific user by ID.
Headers: Authorization: Bearer <token>
Parameters:
id (number): User IDResponse:
json{ "id": 1, "email": "user@example.com", "name": "John Doe", "role": "USER" }
/api/users/email/:emailGet a specific user by email.
Headers: Authorization: Bearer <token>
Parameters:
email (string): User emailResponse:
json{ "id": 1, "email": "user@example.com", "name": "John Doe", "role": "USER" }
/api/users/:idUpdate user information.
Headers: Authorization: Bearer <token>
Parameters:
id (number): User IDRequest Body:
json{ "name": "John Updated", "email": "newemail@example.com" }
/api/users/:idDelete a user.
Headers: Authorization: Bearer <admin-token>
Parameters:
id (number): User ID/api/users/:id/freezer-itemsGet freezer items for a specific user.
Headers: Authorization: Bearer <token>
Parameters:
id (number): User ID/api/users/:id/doc-imagesGet document images for a specific user.
Headers: Authorization: Bearer <token>
Parameters:
id (number): User IDBase URL: /api/food-nutrients
/api/food-nutrientsRetrieve all food nutrients from the database.
Response:
json[ { "id": 1, "mainFoodDescription": "Apples, raw, with skin", "wweiaDescription": "Apple, raw", "energyKcal": 52, "protein": 0.26, "totalFat": 0.17, "carbohydrate": 13.81, "fiber": 2.4, "sugars": 10.39 } ]
/api/food-nutrients/:idRetrieve a specific food nutrient by ID.
Parameters:
id (number): Food nutrient IDResponse:
json{ "id": 1, "mainFoodDescription": "Apples, raw, with skin", "wweiaDescription": "Apple, raw", "energyKcal": 52, "protein": 0.26, "totalFat": 0.17, "carbohydrate": 13.81, "fiber": 2.4, "sugars": 10.39 }
Error Response (404):
json{ "error": "Food nutrient not found" }
/api/food-nutrients/search/descriptionSearch food nutrients by description (searches both mainFoodDescription and wweiaDescription).
Query Parameters:
query (string, required): Search termExample: /api/food-nutrients/search/description?query=apple
Response:
json[ { "id": 1, "mainFoodDescription": "Apples, raw, with skin", "wweiaDescription": "Apple, raw", "energyKcal": 52, "protein": 0.26, "totalFat": 0.17, "carbohydrate": 13.81, "fiber": 2.4, "sugars": 10.39 } ]
/api/food-nutrients/search/kcaloriesSearch food nutrients within a specific calorie range.
Query Parameters:
min (number, required): Minimum caloriesmax (number, required): Maximum caloriesExample: /api/food-nutrients/search/kcalories?min=50&max=100
Response:
json[ { "id": 1, "mainFoodDescription": "Apples, raw, with skin", "wweiaDescription": "Apple, raw", "energyKcal": 52, "protein": 0.26, "totalFat": 0.17, "carbohydrate": 13.81, "fiber": 2.4, "sugars": 10.39 } ]
Error Response (400):
json{ "error": "Min kcalories cannot be greater than max kcalories" }
Base URL: /api/images
/api/images/uploadUpload an image file.
Headers:
Content-Type: multipart/form-dataAuthorization: Bearer <token>Request Body:
image (file): Image file to upload/api/images/:filenameRetrieve an uploaded image.
Parameters:
filename (string): Image filename/api/images/healthCheck image service health.
Response:
json{ "status": "healthy", "timestamp": "2025-07-30T12:00:00.000Z" }
Base URL: /api/body-data (requires token-based authentication)
/api/body-dataCreate new body data entry.
Headers: X-Body-Token: <body-token>
/api/body-dataRetrieve body data entries.
Headers: X-Body-Token: <body-token>
/api/body-data/:idUpdate existing body data entry.
Headers: X-Body-Token: <body-token>
/api/body-data/:idDelete body data entry.
Headers: X-Body-Token: <body-token>
/api/body-data/searchSearch body data entries.
Headers: X-Body-Token: <body-token>
/api/blog/createCreate a new blog post.
/api/blog/:idGet a specific blog post.
/api/blog/:id/viewsIncrement blog post view count.
/api/blog/:id/likeIncrement blog post likes.
/api/blog/:id/unlikeDecrement blog post likes.
/api/blog/:id/commentsAdd a comment to a blog post.
Base URL: /api/scan-doc
/api/scan-doc/analyze-urlGet a pre-signed URL for document analysis.
/api/scan-doc/processProcess a scanned document.
Base URL: /api/db-dashboard (Admin authentication required)
/api/db-dashboard/statsGet database statistics and metrics.
Headers: Authorization: Bearer <admin-token>
/api/db-dashboard/queryExecute a database query.
Headers: Authorization: Bearer <admin-token>
Request Body:
json{ "query": "SELECT * FROM users LIMIT 10" }
400 Bad Request: Invalid request parameters or body401 Unauthorized: Missing or invalid authentication token403 Forbidden: Insufficient permissions404 Not Found: Requested resource not found409 Conflict: Resource already exists (e.g., email already registered)500 Internal Server Error: Server errorjson{ "error": "Error message description" }
400 Bad Request:
json{ "error": "Invalid user ID" }
401 Unauthorized:
json{ "error": "Authentication required" }
404 Not Found:
json{ "error": "Food nutrient not found" }
409 Conflict:
json{ "error": "User with this email already exists" }
500 Internal Server Error:
json{ "error": "Failed to fetch food nutrients" }
Currently, there are no rate limiting restrictions implemented. However, it's recommended to implement rate limiting in production environments.
The API supports Cross-Origin Resource Sharing (CORS) and accepts requests from all origins in the current configuration.
/test-imagesServes a test HTML page for image functionality testing.